﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Sbook.AdminIstrator.ControlAdmin
{
    public partial class MenuTop : System.Web.UI.UserControl
    {
        protected static string Total = "0";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Total = Business.ProductsService.Products_GetByAll().Count.ToString();
                LoadMenuTop();
            }
        }
        private void LoadMenuTop()
        {
            List<Data.CategoryInfo> listC = Business.CategoryService.Category_GetByAll().FindAll(c=>c.cpID=="0");
            ltlMenuTop.Text += "<ul >";
            for (int i = 0; i < listC.Count; i++)
            {
                List<Data.CategoryInfo> listCC = Business.CategoryService.Category_GetByAll().FindAll(c => c.cpID == listC[i].cID);
                
                ltlMenuTop.Text += "<li><a href=\"/AdminIstrator/Products.aspx?p=" + listC[i].cID + "\">" + listC[i].cName +"("+Business.ProductsService.Products_GetByCaId(listC[i].cID).Count.ToString()+") </a><ul >";
                for (int j = 0; j < listCC.Count; j++)
                {
                    ltlMenuTop.Text += "<li><a href=\"/AdminIstrator/Products.aspx?p="+listCC[j].cID+"\">" + listCC[j].cName +"("+Business.ProductsService.Products_GetByCaId(listCC[j].cID).Count.ToString()+") </a></li>";
                }
                ltlMenuTop.Text += "</ul>";
            }
            ltlMenuTop.Text += "</ul>";
        }
         
     
    }
}